<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <a-col :span="8">
            <a-form-model-item label="电脑名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerName">
              <a-input :disabled=formDisabled v-model="model.computerName" placeholder="请输入电脑名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="尺寸" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerSize">
              <a-input :disabled=formDisabled v-model="model.computerSize" placeholder="请输入尺寸"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="cpu" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerCpu">
              <a-input :disabled=formDisabled v-model="model.computerCpu" placeholder="请输入cpu"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="内存" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerInternalStorage">
              <a-input :disabled=formDisabled v-model="model.computerInternalStorage" placeholder="请输入内存"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="硬盘容量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerHardDiskCapacity">
              <a-input :disabled=formDisabled v-model="model.computerHardDiskCapacity" placeholder="请输入硬盘容量"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="颜色" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerColor">
              <a-input :disabled=formDisabled v-model="model.computerColor" placeholder="请输入颜色"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="其他" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerOthers">
              <!-- <a-input :disabled=formDisabled v-model="model.computerOthers" placeholder="请输入其他"  ></a-input> -->
              <a-textarea :disabled="formDisabled" :max-length="500" v-model="model.computerOthers" rows="4" placeholder="请输入其他"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  export default {
    name: 'ErpComputerPurchaseDetailForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        flag: false,
        validatorRules: {
          computerName: [
              { required: true, message: '请输入电脑名称!', trigger: 'blur'},
          ],

        },
        
        model:{
         },
        labelCol: {
        },
        
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 },
        },
        confirmLoading: false,
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.$refs["form"].clearValidate();
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.$emit('ok', this.model, this.flag);
          }
        })
      },
    }
  }
</script>
